package com.epfresh.adapter;

import android.content.Context;
import android.graphics.Bitmap;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.epfresh.R;
import com.epfresh.api.entity.ResponseEntity;
import com.epfresh.api.http.OnRequestListener;
import com.epfresh.api.universalimageloader.core.DisplayImageOptions;
import com.epfresh.api.universalimageloader.core.ImageLoader;
import com.epfresh.api.universalimageloader.core.assist.ImageScaleType;
import com.epfresh.api.universalimageloader.core.display.FadeInBitmapDisplayer;
import com.epfresh.bean.City;
import com.epfresh.bean.ListStore;
import com.epfresh.views.FlexibleRoundedBitmapDisplayer;
import com.google.gson.Gson;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by wzh on 2016/5/6.
 */
public class GridBodyAdapter extends BaseAdapter {
    private LayoutInflater layoutInflater;
    int[] greyImages = new int[]{R.mipmap.grey_restaurant,R.mipmap.grey_office,R.mipmap.grey_market,R.mipmap.grey_fresh,R.mipmap.grey_supper,R.mipmap.grey_other};
    int[] greenImages = new int[]{R.mipmap.green_restaurant,R.mipmap.green_office,R.mipmap.green_market,R.mipmap.green_fresh,R.mipmap.green_supper,R.mipmap.green_other};
    String[] names = new String[]{"餐饮饭店","机关食堂","菜市场" ,"社区生鲜","超市","其他"};
    public int flagPosition = 100;

    private View.OnClickListener onItemClickListener;

    public View.OnClickListener getOnItemClickListener() {
        return onItemClickListener;
    }

    public void setOnItemClickListener(View.OnClickListener onItemClickListener) {
        this.onItemClickListener = onItemClickListener;
    }

    public GridBodyAdapter(Context context, int selectPosition){
        layoutInflater = LayoutInflater.from(context);
        this.flagPosition = selectPosition;
    }
    @Override
    public int getCount() {
        return 6;
    }

    @Override
    public Object getItem(int position) {
        return greyImages[position];
    }

    @Override
    public long getItemId(int position) {
        return position;
    }
/*

    @Override
    public void onClick(View view){
        if(view.getTag(R.id.item_key_status) instanceof Integer){
            flagPosition = (int)view.getTag(R.id.item_key_status);
            notifyDataSetChanged();
            ciName.setContentHintText(hints[flagPosition]);
        }
    }
*/

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View v = layoutInflater.inflate(R.layout.item_body,null);
        ImageView iv = (ImageView) v.findViewById(R.id.iv_body);
        TextView tv = (TextView) v.findViewById(R.id.tv_body);
        iv.setImageResource(greyImages[position]);
        tv.setText(names[position]);
        v.setTag(R.id.item_key_status,position);
        if(position == flagPosition){
            iv.setImageResource(greenImages[position]);
        }
        v.setOnClickListener(onItemClickListener);
        return v;
    }
}